﻿// --------------------------------------------------------------------------------------------------------------------- 
// <copyright file="SA1119StatementMustNotUseUnnecessaryParenthesis.cs" company="StyleCop for ReSharper Development Team">
//   Copyright (c) StyleCop for ReSharper Development Team. All rights reserved.
// </copyright>
// <summary>
//   Defines the SA1119StatementMustNotUseUnnecessaryParenthesis type.
// </summary>
// ---------------------------------------------------------------------------------------------------------------------

namespace StyleCop.For.ReSharper.TestProject.Maintainability
{
    #region Using Directives

    using System;
    using System.Collections.Generic;

    #endregion

    public interface ITest
    {
        #region Public Methods

        string MethodTest();

        #endregion
    }

    public interface ITest2
    {
    }

    public interface IPrimaryKey
    {
        #region Public Properties

        List<IPrimaryKey> Value { get; }

        #endregion
    }

    public class Compare : IPrimaryKey
    {
        #region Public Properties

        public List<IPrimaryKey> Value
        {
            get
            {
                return null;
            }
        }

        #endregion
    }

    [Flags]
    public enum TraceTypes
    {
        /// <summary>
        /// Trace in and out of methods and code blocks.
        /// </summary>
        InOut = 1,
    }

    /// <summary>
    /// </summary>
    internal class SA1119StatementMustNotUseUnnecessaryParenthesis : ITest, ITest2
    {
        public event EventHandler ItemDataBound;

        #region Public Properties
        
        /// <summary>
        /// Gets a value indicating whether tracing in and out of method bodies is enabled.
        /// </summary>
        public bool TraceInOut { get; private set; }
        
        #endregion

        #region Public Methods

        /// <summary>
        /// </summary>
        /// <returns>
        /// </returns>
        public int Method()
        {
            return 6;
        }

        /// <summary>
        /// </summary>
        /// <param name="b">
        /// The b.
        /// </param>
        /// <returns>
        /// </returns>
        public string Method1(int b)
        {
            // Required. (1 set on line)
            var w = 5 + (b * 6);

            w = 1 + (6 / 4);

            w = 1 * (6 - 4);

            var x = (232323 << 12);
            x = (232323 >> 23);

            var q = 6 - (34 % 4);

            var e = q + (6--);
            e = q + (6++);

            var y = (!true);

            // Not required.
            var x = (5 + b);

            // Not required.
            var y = (this.Method()).ToString();

            // Required. (2 sets on line)
            var z = (this as ITest).GetHashCode();

            if (this.GetType() is ITest2)
            {
                var t = 3;
            }
            // Not required.
            return (x.ToString());
        }

        public void Method2()
        {
            // Not required.
            // outermost on the delegate
            this.ItemDataBound += ((sender, e) =>
                { return; });
        }

        public void Method3()
        {
            var options = Options.Some;

            // Required. (2 sets on line)
            if ((options & Options.Some) != Options.None)
            {
                Console.WriteLine("hello");
            }
        }

        public void Method4()
        {
            // Required. (6 sets on line)
            this.Dispatcher.Invoke((Action)(() => ((Example)state).Go()));
        }

        public object[][] Method5()
        {
            return new object[10][];
        }

        public string Method6(int start, int pos)
        {
            // Required. 1 set of paren. here.
            return !(start == pos) ? "Y" : "N";
        }

        string ITest.MethodTest()
        {
            return "s";
        }

        public bool Test5()
        {
            // Not required.
            var a = ((this.GetType() is ITest2)).ToString();
            return false;
        }

        #endregion

        #region Methods

        protected void OnSwitchSettingChanged()
        {
            var compare = new Compare();
            
            // Not required.
            this.TraceInOut = (0 != (129 & (int)TraceTypes.InOut));
            
            // Not required.
            var otherList = (List<IPrimaryKey>)((IPrimaryKey)(compare)).Value;
        }

        #endregion
    }
}